package com.example.coroutine

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelNetworkScope
import com.example.coroutine.net.RedditApi
import kotlinx.coroutines.async
import kotlinx.coroutines.launch

class MainViewModel: ViewModel() {

    fun getData() {
        viewModelNetworkScope.launch {
            val one = async { RedditApi.getInstance().getTop("androiddev", 10) }
            val two = async { RedditApi.getInstance().getTop("androiddev", 10) }
            one.await()
            two.await()
        }
    }
}